/*
 * @Descripttion:
 * @Author: caijj
 * @Date: 2020-12-03 15:14:43
 * @LastEditors: caijj
 * @LastEditTime: 2020-12-09 14:15:25
 */
/* ---------- VUE 配置------------- */
import Vue from 'vue';
import VueCryptojs from 'vue-cryptojs';
import App from './App';
import store from './store';
import router from './router';

/* ---------- CSS文件的引入------------- */
import '@/styles/index.scss'; // global css
import 'normalize.css/normalize.css'; // A modern alternative to CSS resets

/* ----------- UI框架的引入---------- */
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import { UTable, UTableColumn } from 'umy-ui';
import 'umy-ui/lib/theme-chalk/index.css';// 引入样式
import { DatePicker } from 'ant-design-vue';

/* ---------------- 插件、工具、指令的引入  --------------  */
import '@/icons'; // icon
import '@/permission'; // permission control
import '@/utils/directive/debounce'; // 防抖自定义指令
import '@/utils/directive/preventReClick'; // 节流自定义指令
import Cookies from 'js-cookie';
import BasicLayout from '@/layout/BasicLayout';
import KeepAlive from '@/utils/keep-alive';
import moment from 'moment';
import 'moment/locale/zh-cn'; // 汉化操作

/* ---------------全局方法挂载定义 -------------------- */
Vue.prototype.msgSuccess = function(msg) {
  this.$message({ showClose: true, message: msg, type: 'success' });
};

Vue.prototype.msgError = function(msg) {
  this.$message({ showClose: true, message: msg, type: 'error' });
};

Vue.prototype.msgInfo = function(msg) {
  this.$message.info(msg);
};
Vue.prototype.$evBus = new Vue();

Vue.prototype.moment = moment;
/* ---------------------- 组件挂载--------------- ------------- */
Vue.component('BasicLayout', BasicLayout);
Vue.component('BaseKeepAlive', KeepAlive);
/* 使用 umy-ui 中的组件*/
Vue.use(UTable);
Vue.use(UTableColumn);
/* 使用 antd 日期插件 */
Vue.use(DatePicker);
/* set element-ui default size */
Vue.use(ElementUI, {
  size: Cookies.get('size') || 'medium'
});
/* 使用加密VueCryptojs策略*/
Vue.use(VueCryptojs);
// 点击遮罩层不关闭
ElementUI.Dialog.props.closeOnClickModal.default = false;

// 添加根据url是否有hideHeader变量来设置隐藏
if (location.href.indexOf('hideHeader=1') !== -1) {
  store.dispatch('settings/changeSetting', {
    key: 'hideHeader',
    value: true
  });
}
Vue.config.productionTip = false;
new Vue({
  el: '#app',
  router,
  store,
  render: h => h(App)
});
